package online.flowerinsnow.minecraft.bukkit.testffa.runnable;

import online.flowerinsnow.minecraft.bukkit.testffa.core.TestFFACore;
import org.bukkit.Bukkit;

public class CombatTimerRunnable implements Runnable {
    @Override
    public void run() {
        Bukkit.getOnlinePlayers().forEach(p -> {
            int time = TestFFACore.getCombatManager().getCombatTime(p);
            if (time > 0) {
                TestFFACore.getCombatManager().setCombatTime(p, time - 1);
                if (time - 1 <= 0) {
                    TestFFACore.getCombatManager().setCombatTarget(p, null);
                }
            }
        });
    }
}
